@echo off
rem Publish changed files to the shared directory
rem
set pubt=geosoft
set ver=3_2_1
rem Set the log file to keep track of what gets published.
set dest=p:\software\published\bin\utils\%pubt%
if not exist %dest% mkdir %dest%
set log_file=%dest%\%pubt%_v%ver%_published.log
set tee_cmd=tee "%log_file%" /append

echo Publishing %pubt% v%ver% | %tee_cmd%
rem Backup current file before overwriting it
call backup_file_if_exist.cmd "%log_file%"

rem Show who, what, and when.
echo //FILE_TYPE:    %pubt% publish log | %tee_cmd%
echo //AUTHOR:       %USERNAME% | %tee_cmd%
echo //DATE:         %DATE% %TIME% | %tee_cmd%
echo //=================================================== | %tee_cmd%
echo // | %tee_cmd%

rem Create destination
if not exist %dest% mkdir %dest%

rem Avoid publishing backup copies
call pu

rem Allow mods to published copy
if exist %dest%\*.* attrib -r %dest%\*.*

call copy_changes install.cmd %dest% | %tee_cmd%
call copy_changes geosoft_tools.cmd %dest% | %tee_cmd%

set pub_dir=ARKeX_Tools\doc
set tp_dest=%dest%\%pub_dir%
if exist "%pub_dir%" (
   if not exist "%tp_dest%" mkdir "%tp_dest%"
   pushd "%pub_dir%"
      call copy_changes * %tp_dest% | %tee_cmd%
   popd
)

set pub_dir=ARKeX_Tools\gx
set tp_dest=%dest%\%pub_dir%
if exist "%pub_dir%" (
   if not exist "%tp_dest%" mkdir "%tp_dest%"
   pushd "%pub_dir%"
      call copy_changes * %tp_dest% | %tee_cmd%
   popd
)
set pub_dir=ARKeX_Tools\omn
set tp_dest=%dest%\%pub_dir%
if exist "%pub_dir%" (
   if not exist "%tp_dest%" mkdir "%tp_dest%"
   pushd "%pub_dir%"
      call copy_changes * %tp_dest% | %tee_cmd%
   popd
)
set pub_dir=ARKeX_Bar\bar
set tp_dest=%dest%\%pub_dir%
if exist "%pub_dir%" (
   if not exist "%tp_dest%" mkdir "%tp_dest%"
   pushd "%pub_dir%"
      call copy_changes * %tp_dest% | %tee_cmd%
   popd
)
set pub_dir=ARKeX_Bar\bin
set tp_dest=%dest%\%pub_dir%
if exist "%pub_dir%" (
   if not exist "%tp_dest%" mkdir "%tp_dest%"
   pushd "%pub_dir%"
      call copy_changes * %tp_dest% | %tee_cmd%
   popd
)
set pub_dir=ARKeX_Bar\gx
set tp_dest=%dest%\%pub_dir%
if exist "%pub_dir%" (
   if not exist "%tp_dest%" mkdir "%tp_dest%"
   pushd "%pub_dir%"
      call copy_changes * %tp_dest% | %tee_cmd%
   popd
)
set pub_dir=ARKeX_Bar\img
set tp_dest=%dest%\%pub_dir%
if exist "%pub_dir%" (
   if not exist "%tp_dest%" mkdir "%tp_dest%"
   pushd "%pub_dir%"
      call copy_changes * %tp_dest% | %tee_cmd%
   popd
)
set pub_dir=ARKeX_Bar\omn
set tp_dest=%dest%\%pub_dir%
if exist "%pub_dir%" (
   if not exist "%tp_dest%" mkdir "%tp_dest%"
   pushd "%pub_dir%"
      call copy_changes * %tp_dest% | %tee_cmd%
   popd
)

rem Prevent updates to the published copy
attrib +r %dest%\*.*
:end
echo.
